package org.fastiot.gateway.client

import io.netty.channel.Channel
import org.apache.camel.component.netty4.ClientInitializerFactory
import org.apache.camel.component.netty4.NettyProducer

class InitializerFactory extends ClientInitializerFactory {

    @Override
    protected void initChannel(Channel ch) throws Exception {
        def pipeline = ch.pipeline()

        pipeline.addLast("encoder", new BytePacketEncoder())
        pipeline.addLast("decoder", new BytePacketDecoder())
        pipeline.addLast("replyHandler", new ReplyMessageHandler())
    }

    @Override
    ClientInitializerFactory createPipelineFactory(NettyProducer producer) {
        return new InitializerFactory()
    }
}
